from httmock import HTTMock, response
import requests


# def google_mock(url, request):
#     return 'Feeling lucky.'
#
# with HTTMock(google_mock):
#     r= requests.get('http://google.com/')
# print(r.text)


# def response_content(url, request):
#     return {'status_code': 200,
#             'content': 'hello world'}
#
# with HTTMock(response_content):
#     r = requests.get('https://foo_bar')
#
# print(r.status_code)
# print(r.text)


def response_content(url, request):
    headers = {'content-type': 'application/json',
               'Set-Cookie': 'foo=bar;'}
    content = {'message': 'API rate limit exceeded'}
    return response(403, content, headers, None, 5, request)


with HTTMock(response_content):
    r = requests.get('https://api.github.com/users/whatever')

print(r.json())
print(r.cookies['foo'])
print(r.headers)
print(r.status_code)
